	Title  "init"  ;----------------------\
;_________________________________________/
;
	#include   p18f452.inc
;
     GLOBAL    TMR0_init, RX0byte, R0Xfl
;
            UDATA
R0Xfl    res 1
;
            CODE
;*************************************
TMR0_init	   ;Initialize TIMER 0   *
; - - - - - - - - - - - - - - - - - -*
; Timer 0 as a counter.
; TMR0L register counts up to 255. 
;
      movlw    B'01001111'   ;Timer ON, 8bit, External clock,
      movwf    T0CON         ;1:256 Prescale value NOT assigend
      bcf      INTCON,TMR0IE ;disables the TMR0 overflow interrup
      bsf      T0CON,TMR0ON
      return
;
;************************
RX0byte     ; Receive   *
; - - - - - - - - - - - *
; Dont waits for a byte to be received in UART.
; If a byte received the subroutine returns with the byte in WREG.
; R0Xfl : shows if byte received = 1 ; or not = 0 .
;
        bcf     R0Xfl,0 
        btfss   RCSTA,OERR       ;If an overrun has occurred
        bra	    R0X
        bcf     RCSTA, CREN      ; then clear it
        bsf     RCSTA, CREN      ; and reenable receives
R0X          
        btfss   PIR1,RCIF        ;Wait for byte to be received
        bra	    R0Xb
        movf    RCREG,W          ;Put received byte into W
        bsf     R0Xfl,0   
R0Xb    return                   ; End  Delay subroutine.
;
	end	
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

